package instanceofdemo;

class A{
}
class B extends A{
}
class C extends B{
}
class D extends A{
}
class E extends D{
}
class F extends B{
}
public class Demo1 {
	public static void main(String[] args) {
		A a = new A();
		B b = new B();
		C c = new C();
		D d = new D();
		E e = new E();
		F f = new F();
		System.out.println(a instanceof A); // T
		System.out.println(a instanceof B); // F
		System.out.println(a instanceof C); // F
		System.out.println(a instanceof F); // F
		System.out.println(c instanceof A); // T
		System.out.println(c instanceof B); // T
		System.out.println(c instanceof C); // T
		System.out.println(d instanceof A); // T
		System.out.println(d instanceof E); // F
		System.out.println(f instanceof A); // T
		System.out.println(f instanceof B); // T
		System.out.println(e instanceof A); // T
		System.out.println(e instanceof D); // T
	}
}
